{include file="header.htm" /}
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit; min-width:400px;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page" style="min-width: 400px;">
    {include file="bar.htm" /}
    <div class="flexigrid">
        <form class="form-horizontal" id="postHupijiaoPayForm">
            <input type="hidden" name="pay_id" value="{$Config.pay_id}">
            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">
                        <label>支付功能</label>
                    </dt>
                    <dd class="opt">
                        <div class="onoff">
                            <label for="is_open_pay0" class="cb-enable {if condition='!isset($pay_info.is_open_pay) || empty($pay_info.is_open_pay)'}selected{/if}">开启</label>
                            <label for="is_open_pay1" class="cb-disable {if condition='$pay_info.is_open_pay == 1'}selected{/if}">关闭</label>
                            <input id="is_open_pay0" name="pay_info[is_open_pay]" value="0" type="radio" {if condition="!isset($pay_info.is_open_pay) || empty($pay_info.is_open_pay)"} checked="checked"{/if}>
                            <input id="is_open_pay1" name="pay_info[is_open_pay]" value="1" type="radio" {if condition="$pay_info.is_open_pay == 1"} checked="checked"{/if}>
                        </div>
                    </dd>
                </dl>
                <!-- <dl class="row">
                    <dt class="tit">
                        <label>支付终端</label>
                    </dt>
                    <dd class="opt">
                        <ul class="nc-row ncap-waybill-list">
                            <li style="width: 100%;">
                                <label class="label">
                                    <input class="check" type="checkbox" name="pay_terminal[]" value="1" {if condition="in_array(1, $Config.pay_terminal)"} checked="checked" {/if}>电脑端
                                </label>
                                &nbsp; &nbsp;
                                <label class="label">
                                    <input class="check" type="checkbox" name="pay_terminal[]" value="2" {if condition="in_array(2, $Config.pay_terminal)"} checked="checked" {/if}>手机浏览器
                                </label>
                                &nbsp; &nbsp;
                                <label class="label">
                                    <input class="check" type="checkbox" name="pay_terminal[]" value="3" {if condition="in_array(3, $Config.pay_terminal)"} checked="checked" {/if}>手机端微信
                                </label>
                            </li>
                        </ul>
                    </dd>
                </dl> -->
                <dl class="row">
                    <dt class="tit" style="width: auto">
                        <label><b>支付宝配置</b></label>
                    </dt>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="alipay_appid">AppId</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[alipay_appid]" id="alipay_appid" value="{$pay_info.alipay_appid}" class="input-txt">
                        <p class="notic">请输入您的虎皮椒的支付宝AppId，用于支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="alipay_appsecret">AppSecret</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[alipay_appsecret]" id="alipay_appsecret" value="{$pay_info.alipay_appsecret}" class="input-txt">
                        <p class="notic">请输入您的虎皮椒的支付宝AppSecret，用于支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit" style="width: auto">
                        <label><b>微信配置</b></label>
                    </dt>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="wechat_appid">AppId</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[wechat_appid]" id="wechat_appid" value="{$pay_info.wechat_appid}" class="input-txt">
                        <p class="notic">请输入您的虎皮椒的微信AppId，用于支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="wechat_appsecret">AppSecret</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[wechat_appsecret]" id="wechat_appsecret" value="{$pay_info.wechat_appsecret}" class="input-txt">
                        <p class="notic">请输入您的虎皮椒的微信AppSecret，用于支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit" style="width: auto">
                        <label><b>支付网关</b></label>
                    </dt>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="gateway_domain">网关域名</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="pay_info[gateway_domain]" id="gateway_domain" value="{$pay_info.gateway_domain}" class="input-txt" placeholder="例如：https://api.xunhupay.com">
                        <p class="notic">请填写你申请支付通道的平台的域名</p>
                    </dd>
                </dl>
                <dl class="row">
                    <div class="bot" style="padding-bottom:0px;">
                        <a href="JavaScript:void(0);" onclick="SavePayInfo();" class="ncap-btn-big ncap-btn-green" id="submitWechatBtn">确认提交</a>
                        &nbsp;<a href="JavaScript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=10167','虎皮椒支付配置')" style="font-size: 12px;padding-left: 10px;position:absolute;top: 30px">不会配置？</a>
                    </div>
                </dl>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    /*微信支付配置*/
    function SavePayInfo(){
        var is_open_hupijiao = $("#postHupijiaoPayForm input[name='pay_info[is_open_pay]']:checked").val();
        if (is_open_hupijiao == 0) {
            var alipay_appid = $.trim($('#alipay_appid').val());
            var wechat_appid = $.trim($('#wechat_appid').val());
            if (alipay_appid == '' && wechat_appid == '') {
                layer.alert('请填写至少一种支付配置', {icon: 2, title: false});
                return false;
            }

            if (alipay_appid != '') {
                if ($.trim($('#alipay_appsecret').val()) == '') {
                    layer.alert('请填写虎皮椒的支付宝AppSecret', {icon: 2, title: false});
                    return false;
                }
            }

            if (wechat_appid != '') {
                if ($.trim($('#wechat_appsecret').val()) == '') {
                    layer.alert('请填写虎皮椒的微信AppSecret', {icon: 2, title: false});
                    return false;
                }
            }
        }

        layer_loading('正在处理');
        $.ajax({
            url: "{:url('PayApi/save_pay_api_config', ['_ajax'=>1])}",
            type: 'POST',
            dataType: 'JSON',
            data: $('#postHupijiaoPayForm').serialize(),
            success: function(res){
                layer.closeAll();
                if (1 == res.code) {
                    {if condition="$Think.const.CONTROLLER_NAME == 'Weapp'"}
                        layer.msg(res.msg, {icon: 1, time: 1500});
                    {else /}
                        var _parent = parent;
                        _parent.layer.close(parentObj);
                        _parent.layer.msg(res.msg, {shade: 0.3, time: 1000});
                    {/if}
                } else {
                    layer.alert(res.msg, {icon: 5, title: false, closeBtn: false});
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
                return false;
            }
        });
    }
</script>
{include file="footer.htm" /}